<%@page import="cn.kgcnews.pojo.NewsDetail"%>
<%@page import="cn.kgcnews.pojo.PageBean"%>
<%@page import="cn.kgcnews.service.impl.NewsServiceImpl"%>
<%@page import="cn.kgcnews.service.NewsService"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	int ntid = 0;
	String queryTitle = request.getParameter("queryTitle");
	String tid = request.getParameter("ntid");
	if (tid != null && !"".equals(tid)) {
		ntid = Integer.parseInt(tid);
	}
	int currentPageNo = 1; //页码
	int pageSize = 10;
	NewsService newsSerive = new NewsServiceImpl();
	//总页数
	int totalPageCount = newsSerive.queryTotalPageCount(pageSize,
			queryTitle, ntid);
	String pageNo = request.getParameter("pageno");
	if (pageNo != null && !"".equals(pageNo)) {
		currentPageNo = Integer.valueOf(pageNo);
	}
	//控制获取的页码
	if (currentPageNo == 0) {
		currentPageNo = 1;
	}
	if (currentPageNo >= totalPageCount) {
		currentPageNo = totalPageCount;
	}
	PageBean<NewsDetail> pageBean = newsSerive.queryNewsByPageNo(
			currentPageNo, pageSize, queryTitle, ntid);
	//总记录数
	int totalCount = pageBean.getTotalCount();
	pageBean.setCurrPageNo(currentPageNo);
	
	session.setAttribute("bean", pageBean);
	session.setAttribute("queryTitle", queryTitle);
	session.setAttribute("ntid", ntid);
	response.sendRedirect("newslist.jsp");
%>
